import { getUserAPI } from '@/api/user'
export default {
  namespaced: true,
  state() {
    return {
      token: '',
      user: {}
    }
  },
  mutations: {
    updataToKen(state, val) {
      state.token = val
    },
    updateUser(state, val) {
      state.user = val
    }
  },
  actions: {
    async getUser(store) {
      const { data: res } = await getUserAPI()
      if (res.code === 0) {
        store.commit('updateUser', res.data)
      }
    }
  }
}
